package com.gemme.gemme.view;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.gemme.gemme.R;

//首页水平滚动
public class ProductSingleView extends RelativeLayout {
    private Context context;
    public ProductSingleView(Context context) {
        this(context,null);
    }

    public ProductSingleView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ProductSingleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }

    public ProductSingleView setName(String  string) {
        name.setText(string + "");
        return this;
    }

    public ProductSingleView setPrice(String  string) {
        price.setText("¥" +string + "");
        price.setTextColor(Color.parseColor("#ff9d2c2f"));
        return this;
    }

    public ProductSingleView settv_desc(String  string) {
        tv_desc.setText(string + "");
        return this;
    }

    public ProductSingleView setPicture(String  string) {
        Glide.with(context).load(string).into(picture);
        return this;
    }



    TextView name;
    TextView price;
    TextView tv_desc;
    ImageView picture;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.product_single_view,this);
        name = findViewById(R.id.name);
        price = findViewById(R.id.price);
        picture = findViewById(R.id.picture);
        tv_desc = findViewById(R.id.tv_desc);
    }


}
